<?php

/**
 * This file is part of the Codizer package.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @copyright   Copyright (c) 2010 Advisa (http://www.advisa.fr)
 * @author      Codizer Core Team <team@codizer.org>
 * @package     Codizer
 */

function smarty_block_setTplParams($params, $content, &$smarty, &$repeat)
{
    if($repeat == true)
    {
        if(isset($params['lang']) && $params['lang'] != '')
        {
            $smarty->assign('TPL_LANG', $params['lang']);
        }
        
        if(isset($params['localesModule']) && $params['localesModule'] != '')
        {
            $moduleName = $smarty->getModuleName();
            $smarty->assign('TPL_MODULE', $moduleName);
            $smarty->setModuleName($params['localesModule']);
        }
    }
    else
    {
        if(isset($smarty->_tpl_vars['TPL_MODULE']) && !is_null($smarty->_tpl_vars['TPL_MODULE']))
        {
            $smarty->setModuleName($smarty->_tpl_vars['TPL_MODULE']);
            unset($smarty->_tpl_vars['TPL_MODULE']);
        }
    }

    return $content;
}